package com.lb.pdm.controller;

import com.lb.pdm.common.result.GraceJSONResult;
import com.lb.pdm.entity.bo.LoginBO;
import com.lb.pdm.entity.bo.RegisterBO;
import com.lb.pdm.service.SysUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Title: SysUserController
 * @Author Wood
 * @Package com.lb.pdm.controller
 * @Date 2025/10/29 9:37
 * @description: 派出所用户登录
 */
@RestController
@RequestMapping("/sys")
@Tag(name = "系统用户管理", description = "系统用户登录注册相关接口")
public class SysUserController {
    @Autowired
    private SysUserService sysUserService;

    @PostMapping("/login")
    @Operation(summary = "用户登录", description = "系统用户登录接口")
    public GraceJSONResult login(@RequestBody @Valid LoginBO loginBO) {
        return sysUserService.login(loginBO.getUsername(), loginBO.getPassword());
    }

    @PostMapping("/register")
    @Operation(summary = "用户注册", description = "系统用户注册接口")
    public GraceJSONResult register(@RequestBody @Valid RegisterBO registerBO) {
        return sysUserService.register(registerBO);
    }
}
